package com.example.qxfw.shfx.Controller;

import com.dmgis.entity.DmMapPoint;
import com.example.qxfw.common.SysResult;
import com.example.qxfw.common.entity.zy.Flooded;
import com.example.qxfw.shfx.Service.FxyaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.HashMap;
import java.util.List;

@ApiIgnore
@Api(tags = "山洪防汛--防汛预案")
@CrossOrigin
@RestController
@RequestMapping("/FloodPreventionPlanController")
public class FloodPreventionPlanController {

    @Autowired
    private FxyaService fxyaService;

    @ApiOperation("山洪防汛--防汛预案-预案编辑表格")
    @GetMapping("/getAllOfFlooded")
    public SysResult getAllOfFlooded() {
        List<Flooded> allOfFlooded = fxyaService.getAllOfFlooded();
        return SysResult.success(allOfFlooded);
    }

    @ApiOperation("山洪防汛--防汛预案-水文站")
    @GetMapping("/getAllOfWaterStation")
    public HashMap<String, DmMapPoint> getAllOfWaterStation() {
        HashMap<String, DmMapPoint> allOfWaterStation = fxyaService.getAllOfWaterStation();
        return allOfWaterStation;
    }

    @ApiOperation("山洪防汛--防汛预案-保存")
    @PostMapping("/insertOfFlooded")
    public SysResult insertOfFlooded(@RequestBody Flooded flooded) {
        Flooded result = fxyaService.insertOfFlooded(flooded);
        if (result != null) {
            return SysResult.success(result);
        }else{
            return SysResult.fail("添加数据失败！");
        }
    }

    @ApiOperation("山洪防汛--防汛预案-删除")
    @GetMapping("/deleteOfFlooded")
    public SysResult deleteOfFlooded(int id){
        int result = fxyaService.deleteOfFlooded(id);
        return SysResult.success(result);
    }


}
